﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using StairsModuleAndEdit.HYElevator.DataInfo;
using StairsModuleAndEdit.StairsModel.CommonUnit;

namespace StairsModuleAndEdit.HYPutElevator.Kit
{
	internal class Draw2DLegend
	{
		public static List<Curve> Draw(Document Doc, LiftCarParam SizeParam, BlanceWeightPos BalanceWeightPos, double dOffset, XYZ InsertPt)
		{
			List<Curve> list = new List<Curve>();
			double nCarWidth = SizeParam.m_nCarWidth;
			double nCarDepeth = SizeParam.m_nCarDepeth;
			XYZ xyz = new XYZ(InsertPt.X - nCarWidth / 2.0, InsertPt.Y, 0.0);
			list.AddRange(Draw2DLegend.DrawRectangle(xyz, nCarWidth, nCarDepeth, 1));
			double num = Common.MMToFeet(200.0);
			double num2 = Common.MMToFeet(150.0);
			switch (BalanceWeightPos)
			{
			case BlanceWeightPos.BALBEHIND:
				xyz = new XYZ(xyz.X + num, xyz.Y + nCarDepeth + dOffset, 0.0);
				list.AddRange(Draw2DLegend.DrawRectangle(xyz, nCarWidth - 2.0 * num, num2, 0));
				break;
			case BlanceWeightPos.BALRIGHT:
				xyz = new XYZ(xyz.X + nCarWidth + dOffset, xyz.Y + num, 0.0);
				list.AddRange(Draw2DLegend.DrawRectangle(xyz, num2, nCarDepeth - 2.0 * num, 0));
				break;
			case BlanceWeightPos.BALLEFT:
				xyz = new XYZ(xyz.X - dOffset - num2, xyz.Y + num, 0.0);
				list.AddRange(Draw2DLegend.DrawRectangle(xyz, num2, nCarDepeth - 2.0 * num, 0));
				break;
			}
			return list;
		}

		public static List<Curve> DrawRectangle(XYZ LeftDownPt, double dWidth, double dDepth, int nFlg = 0)
		{
			List<Curve> list = new List<Curve>();
			XYZ xyz = new XYZ(LeftDownPt.X, LeftDownPt.Y + dDepth, LeftDownPt.Z);
			XYZ xyz2 = new XYZ(xyz.X + dWidth, xyz.Y, xyz.Z);
			XYZ xyz3 = new XYZ(xyz2.X, xyz2.Y - dDepth, xyz2.Z);
			Line item = Line.CreateBound(LeftDownPt, xyz);
			Line item2 = Line.CreateBound(xyz, xyz2);
			Line item3 = Line.CreateBound(xyz2, xyz3);
			Line item4 = Line.CreateBound(xyz3, LeftDownPt);
			list.Add(item);
			list.Add(item2);
			list.Add(item3);
			list.Add(item4);
			if (nFlg == 1)
			{
				Line item5 = Line.CreateBound(LeftDownPt, xyz2);
				list.Add(item5);
				Line item6 = Line.CreateBound(xyz3, xyz);
				list.Add(item6);
			}
			return list;
		}
	}
}
